export function generateNodeList(treeData, props) {
  const itemList = []
  const fieldMap = {
    label: props.labelField || 'label',
    key: props.keyField || 'id',
    children: props.childrenField || 'children'
  }
  if (Array.isArray(treeData)) {
    const recursion = (data, level, parent) => {
      data.forEach(item => {
        const node = {
          label: item[fieldMap.label], // 节点标签
          key: item[fieldMap.key], // 节点唯一标识
          active: false, // 是否活动节点
          expanded: false, // 是否展开
          status: 'none', // unchecked 未选中，half 半选，checked 已选
          level,// 节点层级
          leaf: true,
          parent,
        }
        itemList.push(node)
        if (item[fieldMap.children] && item[fieldMap.children].length > 0) {
          node.leaf = false
          recursion(item[fieldMap.children], level + 1, node.key)
        }
      })
    }
    recursion(treeData, 0, 'ROOT_NODE')
  } else {
    throw new Error("treeData必须是一个数组！");
  }
  return itemList
}